using System;

namespace RobotRules
{
    /// <summary>
    /// The exception that is thrown when a robot control file has an inappropriate content type.
    /// </summary>
    [Serializable]
    public class ContentTypeException : RobotException
    {
// ReSharper disable InconsistentNaming
        private const string DEFAULT_MESSAGE = "The content type is not valid.";
// ReSharper restore InconsistentNaming


#pragma warning disable 1591
        public string ContentType { get; set; }

        public ContentTypeException(string contentType) : base(DEFAULT_MESSAGE)
        {
            ContentType = contentType;
        }

        public ContentTypeException(string contentType, Exception inner) : base(DEFAULT_MESSAGE, inner)
        {
            ContentType = contentType;
        }

        public ContentTypeException(string message, string contentType) : base(message)
        {
            ContentType = contentType;
        }

        public ContentTypeException(string message, string contentType, Exception inner)
            : base(message, inner)
        {
            ContentType = contentType;
        }
#pragma warning restore 1591
        /// <summary>
        /// When overridden in a derived class, sets the <see cref="T:System.Runtime.Serialization.SerializationInfo"/> with information about the exception.
        /// </summary>
        /// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo"/> that holds the serialized object data about the exception being thrown. </param><param name="context">The <see cref="T:System.Runtime.Serialization.StreamingContext"/> that contains contextual information about the source or destination. </param><exception cref="T:System.ArgumentNullException">The <paramref name="info"/> parameter is a null reference (Nothing in Visual Basic). </exception><filterpriority>2</filterpriority><PermissionSet><IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Read="*AllFiles*" PathDiscovery="*AllFiles*"/><IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="SerializationFormatter"/></PermissionSet>
        public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
        {
            ContentType = info.GetString("ContentType");
            base.GetObjectData(info, context);
        }
    }
}